import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Servlet1 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name1=request.getParameter("name");
        String pwd=request.getParameter("pwd");
        System.out.println(name1+"********"+pwd);

        /*使用user类来测试,EL表达式*/
        User user=new User("zz",11);
        request.setAttribute("User1",user);

         /*
        转发到其他页面,把name带过去
         */
        request.setAttribute("name",name1);

        /*输出到前台列表*/
        User user1=new User("we",12);
        User user2=new User("qera",34);
        User user3=new User("ert",45);
        User user4=new User("hj",32);
        List<User> luser=new ArrayList<User>();
        luser.add(user1);
        luser.add(user2);
        luser.add(user3);
        luser.add(user4);
        request.setAttribute("luser",luser);


        request.getRequestDispatcher("/WEB-INF/demo.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
